﻿Public Class XLThamSo
    Private kn As New KNThamSo
    Public Function LayDSTS() As DataTable
        Return kn.DSTS()
    End Function
    Public Function SaveTS(ByVal data As DataTable) As Boolean
        Return kn.SaveTS(data)
    End Function
    Public Function laytuoi() As Integer
        Dim data As New DataTable
        Dim a, b As Integer
        data = kn.DSTS()
        For Each dr As DataRow In data.Rows
            a = Convert.ToInt32(dr("TuoiMin"))
            b = Convert.ToInt32(dr("TuoiMax"))
        Next
        a = b - a
        Return a
    End Function
    Public Function LayMANV() As String
        Dim data As New DataTable
        Dim s As String = ""
        data = kn.LayMaNV()
        For Each dr As DataRow In data.Rows
            s = dr("MaNV")
            Exit For
        Next
        Return s
    End Function
    Public Function BUS_DKThamSo() As ArrayList
        Dim ds As New ArrayList
        Dim data As New DataTable
        data = kn.DSTS()
        If data.Rows.Count <> 0 Then
            For Each dr As DataRow In data.Rows
                Dim t As New DTO_ThamSo
                t.LuongCB = Convert.ToDouble(dr("LuongCB"))
                t.BHYT = Convert.ToSingle(dr("BHYT"))
                t.BHXH = Convert.ToSingle(dr("BHXH"))
                t.TNCN = Convert.ToSingle(dr("TNCN"))
                t.DKTCN = Convert.ToInt32(dr("DKTNCN"))
                ds.Add(t)
            Next
        Else
            Dim t As New DTO_ThamSo
            t.LuongCB = 0
            t.BHYT = 0
            t.BHXH = 0
            t.TNCN = 0
            t.DKTCN = 0
            ds.Add(t)
        End If
        Return ds
    End Function

    Public Sub KtraThem(ByRef str As DTO_ThamSo, ByVal str1 As String, ByVal str2 As String, ByVal str3 As String, ByVal str4 As String, ByVal str5 As String, ByVal str7 As String, ByVal str8 As String, ByVal str9 As String, ByVal str10 As String)
        str.MaNV = "NV0000"
        If str1 <> "" Then
            str.MaNV = str1
        End If
        str.TuoiMin = 0
        If str2 <> "" Then
            str.TuoiMin = str2
        End If
        str.TuoiMax = 0
        If str3 <> "" Then
            str.TuoiMax = str3
        End If
        str.LuongCB = 0
        If str4 <> "" Then
            str.LuongCB = str4
        End If
        str.NgTrLuong = 0
        If str5 <> "" Then
            str.NgTrLuong = str5
        End If
        str.TNCN = 0
        If str9 <> "" Then
            str.TNCN = str9
        End If
        str.DKTCN = str10
        str.BHYT = 0
        If str7 <> "" Then
            str.BHYT = str7
        End If
        str.BHXH = 0
        If str8 <> "" Then
            str.BHXH = str8
        End If
    End Sub
End Class
